import java.util.Stack;

public class MyQueue2 {
    //用栈实现队列；
    private Stack<Integer> s1;
    private Stack<Integer> s2;
    public MyQueue2(){
        s1=new Stack<>();
        s2=new Stack<>();
    }
    //1.模拟实现向队列中放入元素；
    public void offer(int val){
        s1.push(val);
    }
    //2,模拟实现删除队列中元素；
    public int poll(){
        if(empty()){
            return -1;
        }
        if(s2.isEmpty()){
            while(!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }
    //模拟实现获取队列中元素；
    public int peek(){
        if (empty()) {
            return -1;
        }
        if(s2.isEmpty()) {
            while (!s1.isEmpty()) {
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }
    //模拟判断队列是否为空；
    public boolean empty(){
        return s1.isEmpty()&&s2.isEmpty();
    }

}
